package Game;

public class UsableItem extends Item {
	// CONSTANTS
	
	// DATA
	/**
	 * AP cost to use Item
	 */
	int APCost = 2;
	/**
	 * Maximum range of Item's target
	 */
	int range = 0;
	/**
	 * Type of Item's target
	 */
	int targetType = Card.TARGET_SELF;
	/**
	 * True if Item is consummable, i.e. discarded after usage.
	 */
	boolean consummable = true;
	
	// METHODS
	/**
	 * Creates an Item and sets its properties based on ID.
	 * @param _ID
	 */
	public UsableItem(String _ID) {
		super(_ID);
		setAPCost();
		setRange();
		setTarget();
		setConsummable();
	}
	
	/**
	 * Sets Item's AP Cost based on its ID. Default is 2.
	 */
	private void setAPCost() {
		switch (ID) {
		default:
			APCost = 2;
		}
	}
	
	/**
	 * Sets Item's range based on its ID. Default is 0.
	 */
	private void setRange() {
		switch (ID) {
		default:
			range = 0;
		}
	}
	
	/**
	 * Sets Item's target type based on its ID. Default is self.
	 */
	private void setTarget() {
		switch (ID) {
		default:
			range = Card.TARGET_SELF;
		}
	}
	
	/**
	 * Sets whether Item is consummable based on its ID. Default is true.
	 */
	private void setConsummable() {
		switch (ID) {
		default:
			consummable = true;
		}
	}
	
	/**
	 * Uses character's item on target.
	 * @param character Character which uses the item.
	 * @param target Unit on which the item is used.
	 */
	public void onUse(Character character, ITargetable target) {
		switch (ID) {
		case "8000":	// Potion
			((Unit)target).incHP(5);
			break;
		case "8001":	// Greater Potion
			((Unit)target).incHP(10);
			break;
		case "8002":	// Potent Potion
			((Unit)target).incHP(15);
			break;
		case "8003":	// Magic Potion
			((Unit)target).incMP(5);
			break;
		case "8004":	// Greater Magic Potion
			((Unit)target).incMP(10);
			break;
		case "8005":	// Potent Magic Potion
			((Unit)target).incMP(15);
		}
		
		if (consummable)
			onDiscard(character);
	}
}
